const TOKEN_KEY = 'token';

const isLogin = () => {
  return !!localStorage.getItem(
    `${import.meta.env.VITE_PROJECT_KEY}-${TOKEN_KEY}`
  );
};

const getToken = () => {
  return localStorage.getItem(
    `${import.meta.env.VITE_PROJECT_KEY}-${TOKEN_KEY}`
  );
};

const setToken = (token: string) => {
  localStorage.setItem(
    `${import.meta.env.VITE_PROJECT_KEY}-${TOKEN_KEY}`,
    token
  );
};

const clearToken = () => {
  localStorage.removeItem(`${import.meta.env.VITE_PROJECT_KEY}-${TOKEN_KEY}`);
};

export { TOKEN_KEY, isLogin, getToken, setToken, clearToken };
